﻿using System;
using System.Diagnostics;
using Microsoft.Xna.Framework;
using Terraria.GameContent.UI.Elements;
using Terraria.Localization;
using Terraria.UI;

namespace Terraria.ModLoader.UI
{
	// Token: 0x02000281 RID: 641
	internal class UIEnterSteamIDMenu : UIState
	{
		// Token: 0x06001A2D RID: 6701 RVA: 0x00428058 File Offset: 0x00426258
		public override void OnInitialize()
		{
			UIElement uielement = new UIElement();
			uielement.Width.Set(0f, 0.8f);
			uielement.MaxWidth.Set(600f, 0f);
			uielement.Top.Set(220f, 0f);
			uielement.Height.Set(-220f, 1f);
			uielement.HAlign = 0.5f;
			UIPanel uipanel = new UIPanel();
			uipanel.Width.Set(0f, 1f);
			uipanel.Height.Set(-110f, 1f);
			uipanel.BackgroundColor = new Color(33, 43, 79) * 0.8f;
			uipanel.PaddingTop = 0f;
			uielement.Append(uipanel);
			this.uITextPanel = new UITextPanel<string>(Language.GetTextValue("tModLoader.EnterSteamID"), 0.8f, true);
			this.uITextPanel.HAlign = 0.5f;
			this.uITextPanel.Top.Set(-35f, 0f);
			this.uITextPanel.SetPadding(15f);
			this.uITextPanel.BackgroundColor = new Color(73, 94, 171);
			uielement.Append(this.uITextPanel);
			UITextPanel<string> uitextPanel = new UITextPanel<string>(Language.GetTextValue("UI.Back"), 1f, false);
			uitextPanel.Width.Set(-10f, 0.5f);
			uitextPanel.Height.Set(25f, 0f);
			uitextPanel.VAlign = 1f;
			uitextPanel.Top.Set(-65f, 0f);
			uitextPanel.OnMouseOver += UICommon.FadedMouseOver;
			uitextPanel.OnMouseOut += UICommon.FadedMouseOut;
			uitextPanel.OnClick += this.BackClick;
			uielement.Append(uitextPanel);
			UITextPanel<string> uitextPanel2 = new UITextPanel<string>(Language.GetTextValue("UI.Submit"), 1f, false);
			uitextPanel2.CopyStyle(uitextPanel);
			uitextPanel2.HAlign = 1f;
			uitextPanel2.OnMouseOver += UICommon.FadedMouseOver;
			uitextPanel2.OnMouseOut += UICommon.FadedMouseOut;
			uitextPanel2.OnClick += this.OKClick;
			uielement.Append(uitextPanel2);
			this.steamIDTextField = new UIInputTextField(Language.GetTextValue("tModLoader.PasteSteamID"));
			this.steamIDTextField.HAlign = 0.5f;
			this.steamIDTextField.VAlign = 0.5f;
			this.steamIDTextField.Left.Set(-100f, 0f);
			this.steamIDTextField.OnTextChange += this.OnTextChange;
			uipanel.Append(this.steamIDTextField);
			base.Append(uielement);
		}

		// Token: 0x06001A2E RID: 6702 RVA: 0x00012994 File Offset: 0x00010B94
		private void OKClick(UIMouseEvent evt, UIElement listeningElement)
		{
			Main.PlaySound(10, -1, -1, 1, 1f, 0f);
			ModLoader.SteamID64 = this.steamIDTextField.currentString.Trim();
			Main.SaveSettings();
			Main.menuMode = this.gotoMenu;
		}

		// Token: 0x06001A2F RID: 6703 RVA: 0x000129D1 File Offset: 0x00010BD1
		private void BackClick(UIMouseEvent evt, UIElement listeningElement)
		{
			Main.PlaySound(11, -1, -1, 1, 1f, 0f);
			Main.menuMode = this.gotoMenu;
		}

		// Token: 0x06001A30 RID: 6704 RVA: 0x000129F3 File Offset: 0x00010BF3
		private void VisitRegisterWebpage(UIMouseEvent evt, UIElement listeningElement)
		{
			Main.PlaySound(10, -1, -1, 1, 1f, 0f);
			Process.Start(this.registerURL);
		}

		// Token: 0x06001A31 RID: 6705 RVA: 0x00006B58 File Offset: 0x00004D58
		private void OnTextChange(object sender, EventArgs e)
		{
		}

		// Token: 0x06001A32 RID: 6706 RVA: 0x00012A16 File Offset: 0x00010C16
		internal void SetGotoMenu(int gotoMenu)
		{
			this.gotoMenu = gotoMenu;
		}

		// Token: 0x04001775 RID: 6005
		private string registerURL = "http://javid.ddns.net/tModLoader/register.php";

		// Token: 0x04001776 RID: 6006
		public UITextPanel<string> uITextPanel;

		// Token: 0x04001777 RID: 6007
		internal UIInputTextField steamIDTextField;

		// Token: 0x04001778 RID: 6008
		private int gotoMenu;
	}
}
